package com.yzc.dao.imp;

import com.yzc.Eqlil.zhaun;
import com.yzc.dao.Zengjai;
import com.yzc.util.AliPool;
import com.yzc.util.DbUtil;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.Connection;
import java.util.List;

public class zengim implements Zengjai {
    QueryRunner qRunner=new QueryRunner();
    @Override
    public int exezeng(Object[] obj) throws Exception {
        String sql="insert into xinxi(topic,Thetitle,knowledge,Theanswer,shitijiexi) values('"+obj[0]+"','"+obj[1]+"','"+obj[2]+"','"+obj[3]+"','"+obj[4]+"')";
        System.out.println(sql);
        Connection connection= AliPool.getConn();
        int a=qRunner.execute(connection,sql);
        connection.close();
        return a;
    }

    @Override
    public List cha(Object name) throws Exception {
        String sql="SELECT id FROM xinxi where Thetitle='"+name+"'";
        System.out.println(sql);
        Connection connection=AliPool.getConn();
        List list=qRunner.query(connection, sql,new BeanListHandler<zhaun>(zhaun.class));
        connection.close();
        return list;
    }

    @Override
    public int xuan(Object objecs,int a) throws Exception {
        String sql="insert into shixuanti(shixuan,xinxi) values('"+objecs+"', "+ a +")";
        Connection connection= AliPool.getConn();
        int p=qRunner.execute(connection,sql);
        connection.close();
        return p;
    }
}
